package com.zx.springboot.producer;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zx.springboot.config.RabbitmqConfig;

/***
 * 消息队列生产者
 * 
 * @author Administrator
 *
 */
@Component
public class MessegeProducer {

	/***
	 * 发送消息到直连队列
	 */
	@Autowired
	private AmqpTemplate amqpTemplate;

	public void sendDirectQueue(Object jsonStr) {
		// 第一个参数是指要发送到哪个队列里面， 第二个参数是指要发送的内容
		this.amqpTemplate.convertAndSend(RabbitmqConfig.QUEUE, jsonStr);
		
		
	}
	
	public static final String TOPIC_KEY = "a.hello.b";//该类型的实践
	public void sendTopicQueue2(Object jsonStr)  {
		this.amqpTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPIC,
				TOPIC_KEY,jsonStr);
	}

}
